Skip to content

fix: extract text from React elements in slugifyMarkdownHeadline to fix code-wrapped heading anchors#2349

Closed
Divyansh200102 wants to merge 1 commit intojson-schema-org:mainfrom
Divyansh200102:fix-heading-anchors
Closed

fix: extract text from React elements in slugifyMarkdownHeadline to fix code-wrapped heading anchors#2349
Divyansh200102 wants to merge 1 commit intojson-schema-org:mainfrom
Divyansh200102:fix-heading-anchors

Conversation

@Divyansh200102
Copy link

What kind of change does this PR introduce?
Bugfix

Issue Number:

Screenshots/videos:
(see issue #2341 for reproduction video)

After
image
image

Summary
Section headers wrapped in backticks (e.g. #### `Schema`) were rendered by markdown-to-jsx as React <code> elements, not plain strings. slugifyMarkdownHeadline only handled string children, so it returned "" for these headings — causing href="#" in the ToC (scroll to top) and "" === "" matching all headings at once (all highlighted).

Added extractTextFromNode to recursively extract text from React elements, so `Schema` now correctly produces the slug schema.

Does this PR introduce a breaking change?
No.

Checklist

@github-actions
Copy link

Hi @Divyansh200102! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: completed checklist items

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Mar 18, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 85e7c8b

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5ca1483) to head (85e7c8b).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2349   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          672       672           
  Branches       211       211           
=========================================
  Hits           672       672           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-project-automation github-project-automation bot moved this from Ready to review to Done in PR - Triage Group Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 Bug:Clicking section header scrolls to top and highlights all headers

1 participant